package cn.edu.njuit.lesson9heros.apis;

import cn.edu.njuit.lesson9heros.pojo.Hero;
import cn.edu.njuit.lesson9heros.pojo.Team;
import cn.edu.njuit.lesson9heros.service.HeroService;
import cn.edu.njuit.lesson9heros.service.TeamService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/api")
public class HeroApi {
    @Autowired
    TeamService teamService;
    @Autowired
    HeroService heroService;

    @GetMapping("/team")
    public ResponseEntity getTeam(){
        Team result=teamService.getTeam(null);
        return ResponseEntity.ok(result);
    }

    @GetMapping("/hero")
    public ResponseEntity getHero(String position){
        Hero result=heroService.getHeroByPosition(position);
        return ResponseEntity.ok(result);
    }
}
